﻿using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using AmazeUI.bll.GetModel;
using AmazeUI.db;
using WebCommon;

namespace AmazeUI.bll
{
    public class XtNasBll : BaseBll
    {
        IQueryable<XtNav> Where()
        {
            return this.db.XtNav.Where(a => a.IsEna);
        }

        /// <summary>
        /// LEI
        /// </summary>
        /// <returns></returns>
        public IEnumerable<XtNav2 > GetNases()
        {
            var where = this.Where().ToList();
            var pars =
                where.Where(a => a.ParentId == 0)
                    .Select(WebCommon.StringCommand.Static.ParentToSub<XtNav, XtNav2>).ToList();
            foreach (var item in pars)
            {
                item.XtNav2S = where.Where(x => x.ParentId == item.Sid).Select(WebCommon.StringCommand.Static.ParentToSub<XtNav, XtNav2>).ToList();
            }
            return pars;
       
        }
        /// <summary>
        /// 数据列表
        /// </summary>
        /// <param name="rows"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public PageListJs<XtNav> GetList(int rows, int page)
        {
           var where= this.Where();
           return new PageListJs<XtNav>(where, rows, page);
         
        }
    }
}